package org.yjc.service;

import java.util.List;
import java.util.Optional;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.stereotype.Service;
import org.yjc.entity.TbClass;
import org.yjc.repository.TbClassRepository;

@Service
public class TbClassService {
	@Autowired
	private TbClassRepository tbClassDAO;

	public Page<TbClass> findAll(Pageable pageable) {
		return tbClassDAO.findAll(pageable);
	}

	public void deleteById(Integer id) {
		tbClassDAO.deleteById(id);
		
	}

	public void save(TbClass tbclass) {
		tbClassDAO.save(tbclass);
		
	}
	public Page<TbClass> findAll(Specification spec, Pageable pageable) {
		return tbClassDAO.findAll(spec,pageable);
	}

	public List<TbClass> findAll() {
		return tbClassDAO.findAll();
	}

	public TbClass findById(Integer tbclassid) {
		Optional<TbClass> optional = tbClassDAO.findById(tbclassid);
		if(optional.isPresent()) {
			return optional.get();
		}
		return null;
	}
}
